********************************************************************************
**** 		 			HUT ANALYSIS
********************************************************************************
clear all
set more off                          

use "use/final_hut", clear

global controls age age2 female educ married no_adults no_kids unemployed

global muni_controls avg_age share_poor share_loweduc share_selfemployed share_female avg_kids share_married lnp50_muni lnhouseprice population


* Table 7, Panel B
eststo clear

eststo: areg lnsavings yitz_muni lndispinc_hut lndispinc_hut2 $controls $muni_controls i.year [aw=weight], cluster(municipality) a(muni) robust

eststo: areg lnsavings yitz_muni lndispinc_hut lndispinc_hut2 $controls $muni_controls i.year [aw=weight] if dispinc_hut<=p50_muni, cluster(municipality) a(muni) robust

eststo: areg lnsavings yitz_muni lndispinc_hut lndispinc_hut2 $controls $muni_controls i.year [aw=weight] if dispinc_hut>p50_muni, cluster(municipality) a(muni) robust

esttab using "out/tables/table7.tex", label replace se


gen male=cond(female==0,1,0)


* Table 9
set more off

local depvar="visible_share"

foreach var in male female {
	
eststo clear

eststo: areg `depvar' yitz_muni lndispinc_hut $controls $muni_controls i.year [aw=weight] if `var'==1, cluster(municipality) a(muni) robust
estadd local YearFE "Yes"
estadd local IndividualControls "Yes"
estadd local MunicipalityFE "Yes"

eststo: areg `depvar' yitz_muni lndispinc_hut $controls $muni_controls i.year [aw=weight] if dispinc_hut<p25_muni & `var'==1, cluster(municipality) a(muni) robust
estadd local YearFE "Yes"
estadd local IndividualControls "Yes"
estadd local MunicipalityFE "Yes"

eststo: areg `depvar' yitz_muni lndispinc_hut $controls $muni_controls i.year [aw=weight] if dispinc_hut>=p25_muni & dispinc_hut<p50_muni & `var'==1, cluster(municipality) a(muni) robust
estadd local YearFE "Yes"
estadd local IndividualControls "Yes"
estadd local MunicipalityFE "Yes"

eststo: areg `depvar' yitz_muni lndispinc_hut $controls $muni_controls i.year [aw=weight] if dispinc_hut>=p50_muni & dispinc_hut<p75_muni & `var'==1, cluster(municipality) a(muni) robust
estadd local YearFE "Yes"
estadd local IndividualControls "Yes"
estadd local MunicipalityFE "Yes"

eststo: areg `depvar' yitz_muni lndispinc_hut $controls $muni_controls i.year [aw=weight] if dispinc_hut>=p75_muni & `var'==1, cluster(municipality) a(muni) robust
estadd local YearFE "Yes"
estadd local IndividualControls "Yes"
estadd local MunicipalityFE "Yes"

if var=="male" {
esttab using "out/tables/table9.tex", label replace se
}

else {
esttab using "out/tables/table9.tex", label append se
}
}			
